package com.fiume.travel.mapperExt;

import com.fiume.travel.pojo.Route;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * <p>
 * Description:
 * </p>
 *
 * @author fiume
 * @version v1.0.0
 * @create 2021-02-21 20:57
 * @see com.fiume.travel.mapperExt
 */
@Mapper
public interface FavoriteMapperExt {

    @Select("SELECT tr.* " +
            "FROM `tab_favorite` AS tf " +
            "LEFT JOIN tab_route AS tr ON tf.route_id = tr.id " +
            "WHERE user_id = #{userId,jdbcType=BIGINT}")
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="route_name", property="routeName", jdbcType=JdbcType.VARCHAR),
            @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
            @Result(column="route_Introduce", property="routeIntroduce", jdbcType=JdbcType.VARCHAR),
            @Result(column="flag", property="flag", jdbcType=JdbcType.CHAR),
            @Result(column="is_theme_tour", property="isThemeTour", jdbcType=JdbcType.CHAR),
            @Result(column="attention_count", property="attentionCount", jdbcType=JdbcType.INTEGER),
            @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
            @Result(column="seller_id", property="sellerId", jdbcType=JdbcType.BIGINT),
            @Result(column="created_time", property="createdTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Route> findFavoriteByUserId(@Param("userId") Long userId);
}
